import { request } from '@/utils/request';
import { RequestEnum } from '@/enums/httpEnum';

export const userApi = {
  userList: '/user/list',
  userDetail: '/user/detail',
  userAdd: '/user/add',
  userUpdate: '/user/update',
  userDelete: '/user/delete',
  userDisable: '/user/disable',
} as const;

export const createUser = (data: API.CreateUserParams) => {
  return request({
    url: userApi.userAdd,
    method: RequestEnum.POST,
    data,
  });
};

export const updateUser = (data: API.UpdateUserParams) => {
  return request({
    url: userApi.userUpdate,
    method: RequestEnum.PUT,
    data,
  });
};

export const deleteUser = (params: { id: number }) => {
  return request({
    url: userApi.userDelete,
    method: RequestEnum.DELETE,
    params,
  });
};

export const disableUser = (data: API.updateIsLockDTO) => {
  return request({
    url: userApi.userDisable,
    method: RequestEnum.POST,
    data,
  });
};
